define(['jquery', 'toastr', 'form', 'template'], function ($, toastr, Form, Template) {
	var Controller = {
		mounted: function () {
			var that = this;
			that._render();
			that._bind();

		},
		_render: function () {
			var that = this;
			console.log('_render');
			var dom = $("#register-form");
			var csminvite = that.getQueryString("csminvite");
			var csminvitesign = that.getQueryString("csminvitesign");

			if (csminvite != null && csminvite != "") {
				dom.append('<input type="hidden" name="csminvite" value="' + csminvite + '"/>');
				dom.append('<input type="hidden" name="csminvitesign" value="' + csminvitesign + '"/>');
			} else {
				//1.0.2
				//如果需要邀请码，则显示邀请码输入框
				if (Config.csminvite.isspportinvcode == 'Y') {
					var rule = "required;";
					//如果是非邀请用户允许注册，则邀请码不必填
					if (Config.csminvite.canregisteroutinvite == 'Y') {
						rule = "";
					}
					dom.prepend('\
						<div class="form-group">\
							<label class="control-label required">邀请码<span class="text-success"></span></label>\
							<div class="controls">\
								<input type="text" name="csminvcode" id="csminvcode" data-rule="' + rule + '" class="form-control input-lg" placeholder="邀请码">\
								<p class="help-block"></p>\
							</div>\
						</div>\
					');
				}
				// Fast.api.ajax({
				// 	url: window.Config.__ROOT__+"/addons/csminvite/indexajax/getInviteInfo",
				// 	type: "get",
				// }, function (data, ret) {
				// 	console.log(data);
				// 	//如果有邀请链接进入，则不添加邀请码
				// 	return false;
				// }, function (data, ret) {
				// 	return false;
				// });				
			}

		},
		_bind: function () {
			var that = this;
			console.log('_bind');
		},
		getQueryString: function (name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if (r != null) return unescape(r[2]);
			return null;
		}
	};
	return Controller;
});